package com.xiaoma.factory.demo;

import com.xiaoma.factory.Shape;
import com.xiaoma.factory.ShapeFactory;

/**
 * @description  
 * @author wangtianxiang
 * @date: 2021/7/2 16:21
 */
public class FactoryPatternDemo {

    public static void main(String[] args) {
        ShapeFactory shapeFactory = new ShapeFactory();

        //获取circle的对象,并调用它的draw方法
        Shape shape1 = shapeFactory.getShape("CIRCLE");

        //调用 Circle的draw 方法
        shape1.draw();

        //获取 Rectangle的对象，并调用它的 draw 方法
        Shape shape2 = shapeFactory.getShape("RECTANGLE");

        //调用Rectangle的draw方法
        shape2.draw();

        //获取Square的对象,并调用它的darw方法
        Shape shape3  = shapeFactory.getShape("SQUARE");

        //调用Square的draw方法
        shape3.draw();
    }
}
